﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace ZhangZhao.Web.H_UserContact
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int Id=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(Id);
				}
			}
		}
			
	private void ShowInfo(int Id)
	{
		ZhangZhao.BLL.H_UserContact bll=new ZhangZhao.BLL.H_UserContact();
		ZhangZhao.Model.H_UserContact model=bll.GetModel(Id);
		this.lblId.Text=model.Id.ToString();
		this.txtUserName.Text=model.UserName;
		this.txtEmail.Text=model.Email;
		this.txtPhone1.Text=model.Phone1;
		this.txtPhone2.Text=model.Phone2;
		this.txtWeiBo.Text=model.WeiBo;
		this.txtWeiXin.Text=model.WeiXin;
		this.txtQQ.Text=model.QQ;
		this.txtWebsite.Text=model.Website;
		this.txtHomeAddress.Text=model.HomeAddress;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtUserName.Text.Trim().Length==0)
			{
				strErr+="UserName不能为空！\\n";	
			}
			if(this.txtEmail.Text.Trim().Length==0)
			{
				strErr+="Email不能为空！\\n";	
			}
			if(this.txtPhone1.Text.Trim().Length==0)
			{
				strErr+="Phone1不能为空！\\n";	
			}
			if(this.txtPhone2.Text.Trim().Length==0)
			{
				strErr+="Phone2不能为空！\\n";	
			}
			if(this.txtWeiBo.Text.Trim().Length==0)
			{
				strErr+="WeiBo不能为空！\\n";	
			}
			if(this.txtWeiXin.Text.Trim().Length==0)
			{
				strErr+="WeiXin不能为空！\\n";	
			}
			if(this.txtQQ.Text.Trim().Length==0)
			{
				strErr+="QQ不能为空！\\n";	
			}
			if(this.txtWebsite.Text.Trim().Length==0)
			{
				strErr+="Website不能为空！\\n";	
			}
			if(this.txtHomeAddress.Text.Trim().Length==0)
			{
				strErr+="HomeAddress不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int Id=int.Parse(this.lblId.Text);
			string UserName=this.txtUserName.Text;
			string Email=this.txtEmail.Text;
			string Phone1=this.txtPhone1.Text;
			string Phone2=this.txtPhone2.Text;
			string WeiBo=this.txtWeiBo.Text;
			string WeiXin=this.txtWeiXin.Text;
			string QQ=this.txtQQ.Text;
			string Website=this.txtWebsite.Text;
			string HomeAddress=this.txtHomeAddress.Text;


			ZhangZhao.Model.H_UserContact model=new ZhangZhao.Model.H_UserContact();
			model.Id=Id;
			model.UserName=UserName;
			model.Email=Email;
			model.Phone1=Phone1;
			model.Phone2=Phone2;
			model.WeiBo=WeiBo;
			model.WeiXin=WeiXin;
			model.QQ=QQ;
			model.Website=Website;
			model.HomeAddress=HomeAddress;

			ZhangZhao.BLL.H_UserContact bll=new ZhangZhao.BLL.H_UserContact();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
